package old.ships;

import java.util.Collection;

//executes messages, handles ordinary behavior of formations

public class FormationExecutor 
{
	private String hostType;  //type of containing object
	private Formation host;  //reference to containing object
	
	public FormationExecutor(CombatObjectEnum type, Formation host)
	{
		hostType = type.toString();
		this.host = host;
	}
	
	//handles all actions from received messages
	public void go()
	{
		String message;
		CombatObject content;
		
		//acquire current message
		message = host.communicator.getMessage();
		//check message validity before execution
		if (this.isValid(message))
		{
			//grab content of message
			content = host.communicator.getContent();
			
			if (message.equalsIgnoreCase("OVERWRITE_WAYPTS"))
			{
				host.addMove((Collection<MapCoordinate>) content);				
			}
			else if (message.equalsIgnoreCase("OVERWRITE_WAYPTS_ALLSPEED"))
			{
				host.addMove((Collection<MapCoordinate>) content);				
			}
			else if (message.equalsIgnoreCase("ADD_WAYPTS"))
			{
				host.addWaypt((Collection<MapCoordinate>) content);
			}
			else if (message.equalsIgnoreCase("ADD_WAYPTS_ALLSPEED"))
			{
				host.addWaypt((Collection<MapCoordinate>) content);
			}
			else if (message.equalsIgnoreCase("REM_WAYPTS"))
			{
				host.remWaypt((Collection<MapCoordinate>) content);
			}
			else if (message.equalsIgnoreCase("SCATTER"))
			{
								
			}
			else if (message.equalsIgnoreCase("ADD_SHIP"))
			{
				host.addShip((Collection<CombatShip>) content);
			}
			else if (message.equalsIgnoreCase("REM_SHIPS"))
			{
				host.remShip((Collection<CombatShip>) content);
			}
			else if (message.equalsIgnoreCase("FORMATION_COLUMNS"))
			{
				
			}
			else if (message.equalsIgnoreCase("FORMATION_CIRCLE"))
			{
				
			}
			else if (message.equalsIgnoreCase("FORMATION_VANGUARD"))
			{
				
			}
			else if (message.equalsIgnoreCase("FORMATION_HALFCIRCLE"))
			{
				
			}
			else if (message.equalsIgnoreCase("FORMATION_STAGGERED"))
			{
				
			}
			else if (message.equalsIgnoreCase("OVERWRITE_STOP"))
			{
				
			}
			else if (message.equalsIgnoreCase("STOP"))
			{
				
			}
			else if (message.equalsIgnoreCase("GO"))
			{
				
			}
			else if (message.equalsIgnoreCase("RETREAT"))
			{
				
			}
			else if (message.equalsIgnoreCase("JUMP_TO"))
			{
				
			}
			else
			{
				
			}			
		}		
	}
	
	private boolean isValid(String message)
	{
		return ObjectMessageCheck.validMessage(hostType, message);
	}
	

}
